//build linux darwin openbsd freebsd

package jvm

import (
	"os/exec"
	"path/filepath"
)

func GetJvmCommandPath() (string, error) {
	p, err := exec.LookPath("java")
	if err != nil {
		p = "/usr/bin/java"
	}
	path, err := filepath.EvalSymlinks(p)
	if err != nil {
		path, err = filepath.EvalSymlinks("/etc/alternatives/java")
	}
	return filepath.Dir(path), err
}

func GetJpsPath() (string, error) {
	p, err := GetJvmCommandPath()
	jps := filepath.Join(p, "jps")
	return jps, err
}
